package cn.tedu.tmall.basic.controller;

import cn.tedu.tmall.basic.service.IDistrictService;
import cn.tedu.tmall.common.pojo.po.DistrictSimplePO;
import cn.tedu.tmall.common.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "查询省、市、区")
@RestController
@RequestMapping("/district")
public class DistrictController {
    @Autowired
    private IDistrictService service;
    @ApiOperation("根据父级id查询子级")
    @ApiOperationSupport(order = 100)
    @GetMapping("/list-by-parentId")
    @ApiImplicitParam(name = "parentId", value = "父级ID", dataType= "long", required = true)
    public JsonResult listByParentId(Long parentId){
        List<DistrictSimplePO> districtSimplePOS = service.listByParent(parentId);
        return JsonResult.ok(districtSimplePOS);
    }
}
